/*
 * Example01.java
 *
 * Created on 19 gennaio 2008, 17.17
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.cnr.icib.flora2engine.examples;

import it.cnr.icib.flora2engine.Flora2;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Vector;
import net.sourceforge.flora.javaAPI.src.FloraMethod;
import net.sourceforge.flora.javaAPI.src.FloraObject;

/**
 *
 * @author Nino
 */
public class Example03 {
    
    /** Creates a new instance of Example01 */
    public Example03() {
    }
    
    public static void main(String[] args) {
        
        String curDir = System.getProperty("user.dir");
        
        System.out.println(curDir);
        Flora2 session = new Flora2("/Applications/XSB/config/i386-apple-darwin11.4.0/bin",
                                    "/Applications/XSB/packages/flora2");
      
        session.setPath(curDir + "/florasrc");
        
        String fileName = "person";
        String moduleName = "test";
        
        
        if(fileName == null || fileName.trim().length() == 0) {
            System.out.println("Invalid path to example file!");
            System.exit(0);
        }
        
        session.loadFile(fileName,moduleName);
        
        /* Examples of uses of the low-level Java-FLORA-2 API */
        
        
        String command="";
      
        FloraObject personObj = new FloraObject("person",session.getFloraSession());
        
        
        Iterator methIter = personObj.getMethods(moduleName);
        while (methIter.hasNext()) {
            System.out.println(((FloraMethod)methIter.next()).methodDetails());
        }

        System.out.println();

        
        // instances of the person class
        Iterator instanceIter = personObj.getInstances(moduleName);
        System.out.println("Person instances:");
        while (instanceIter.hasNext())
            System.out.println("    " + (FloraObject)instanceIter.next());
        
        
        Iterator subIter = personObj.getSubClasses(moduleName);
        System.out.println("Person subclasses:");
        while (subIter.hasNext())
            System.out.println("    " + (FloraObject)subIter.next());
        
         subIter = personObj.getDirectSubClasses(moduleName);
        System.out.println("Person direct subclasses:");
        while (subIter.hasNext())
            System.out.println("    " + (FloraObject)subIter.next());
        
        
         Iterator supIter = personObj.getSuperClasses(moduleName);
        System.out.println("Person superclasses:");
        while (supIter.hasNext())
            System.out.println("    " + (FloraObject)supIter.next());
        
        supIter = personObj.getDirectSuperClasses(moduleName);
        System.out.println("Person direct superclasses:");
        while (supIter.hasNext())
            System.out.println("    " + (FloraObject)supIter.next());
          
        
        instanceIter = personObj.getDirectInstances(moduleName);
        System.out.println("Person direct instances:");
        while (instanceIter.hasNext())
            System.out.println("    " + (FloraObject)instanceIter.next());
   
        
        
        
       
       
        
        
        // Close session and good bye
        session.close();
        System.exit(0);
    }
}
